<?php
/**
 * return array(array(	'auctionID' => 'string,
 * 						'auctionName' => 'string',
  	 					'productID'=> 'string',
  	 					'origion_price' => 'double',
  	 					'status'=> 'string(open,close)',
  	 					'timeleft' => 'long',
  	 					'aution_price'=> 'double',
  	 					'current_user_bid'=> 'userID: string',
  	 					'price_per_bid' => 'int'))
 */

include_once '../pages/config.php';

function view_auction(){
	$connection = mysql_connect($host, $username, $password) or die($connect_error.mysql_error());
  	mysql_select_db("mydb",$connection) or die($connect_error.mysql_error());
  	$result = @mysql_query("select * from auction_view",$connection);
  	 		$arr = array();
  	while ($row = @mysql_fetch_array($result,MYSQL_NUM)){
  	 	 

  	 		$arr = array_merge ( $arr, array(array('auctionID' => $row[0],
  	 					'auctionName' => $row[1],
  	 					'productID'=> $row[2],
  	 					'origion_price' => $row[3],
  	 					'status'=> $row[4],
  	 					'timeleft' => $row[5],
  	 					'aution_price'=> $row[6],
  	 					'current_user_bid'=> $row[7],
  	 					'price_per_bid' => $row[8])));
  	}
	echo json_encode($arr);
	
	die(json_encode($arr));
	
  	 
}
view_auction();
